﻿@model Dinamico.Models.ContentPage
@{
	Content.Define(re => 
	{
		re.Title = "Container";
		re.CheckBox("ShowDescendants", "Show all descendants");
		re.Add(new N2.Details.EditableDefinitionAttribute { Name = "ListingType", Title = "Listed type", TemplateSelection = true, RemovedTypes = new[] { typeof(N2.Definitions.ISystemNode) }, DefaultValue = "ContentPage/News" });
	});
}

@Html.Partial("LayoutPartials/Content")
@{ 
	Content.Register.FreeText("NewsFooter", "News item footer").Help("Text displayed as footer for each news item");
	Content.Register.RegisterDisplayable<N2.Details.DisplayableTokensAttribute>("NewsFooter");
}

@{
	var items = Content.Data.ShowDescendants ?? false
		? Content.Traverse.DescendantPages(Content.Current.Page, Content.Is.Accessible())
		: Content.Traverse.Children(Content.Current.Page, Content.Is.Accessible());
	if (Content.Has.ListingType)
	{
		items = items.Where(Content.Is.Definition((string)Content.Data.ListingType));
	}
}
@Html.Loop(items,
	template: @<div class="list-item">
		@Html.Partial("Partials/ContentLink", item.Data)
	</div>,
	wrapper: @<div class="list">@item.RenderContents()</div>,
	empty: @<p>No items</p>)